
const {Router} = require('express')
let router = new Router()

const typeModel = require('../models/typeModel')

router.get('/typeInfo',async (req,res) => {
    const {name} = req.query
    if(name){
        let typeItem = await typeModel.findOne({name})
        if(typeItem){
            res.send({success:true,data:typeItem})
        }else{
            res.send({success:false,message:'查询失败'})
        }
    }else{
        let AlltypeInfo = await typeModel.find()
        if(AlltypeInfo){
            res.send({success:true,data:AlltypeInfo})
        }else{
            res.send({success:false,message:'查询失败'})
        }
    }
    
    
})



module.exports = router